<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改项目方案组')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-plan-edit" th:object="${plan}">
            <input name="planId" th:field="*{planId}" type="hidden">
            <input id="items" name="items" th:field="*{items}" type="hidden">
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "kt/plan";
        $("#form-plan-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	var rows = $.table.selectFirstColumns();
            	$("#items").val(rows.join());
                $.operate.save(prefix + "/edit", $('#form-plan-edit').serialize());
            }
        }
        
        $(function() {
            var options = {
            	data:[[${itemList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                uniqueId: "topicItemId",
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'topicItemId',
                    title: '项目ID',
                    visible: false,
                },
                {
                    field: 'itemSort',
                    title: '项目排序'
                },
                {
                    field: 'itemType',
                    title: '项目类型'
                },
                {
                    field: 'itemTypeName',
                    title: '项目类型名称'
                }
               ]
            };
            $.table.init(options);
            
            var items = [];
    	    $.each($("input[name='items']").val().split(","), function(i, n) {
    	    	items.push(Number(n))
    	    });
    	    $('#bootstrap-table').bootstrapTable('checkBy', {field: 'topicItemId', values:items});
        });
    </script>
</body>
</html>